from subprocess import Popen, PIPE

def run_cmd(cmd):
    p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE, universal_newlines=True)
    p.wait()
    out = [l.strip() for l in p.stdout.readlines()]
    err = [l.strip() for l in p.stderr.readlines()]
    return out, err


if __name__ == '__main__':
    import sys
    from urllib.parse import quote, unquote
    out, err = run_cmd(sys.argv[1])
    print(quote('\n'.join(out)))
    print(err)

